package com.huang.day2;


import java.util.ArrayList;
import java.util.Iterator;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author HuangShen
 * @Description
 * @create 2021-04-01 12:11
 */
public class Test1 {

    public static void main(String[] args) throws ExecutionException, InterruptedException {

        int[] ints = new int[10];
        System.out.println(ints.length);

        FutureTask<Integer> task = new FutureTask<>(() -> {

            Thread.sleep(1000);
            System.out.println("任务返回");
            return 123;
        });

        Thread t1 = new Thread(task, "t1");
        t1.start();
        System.out.println(task.get());


        ArrayList<Integer> arr = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            arr.add(i);
        }
        Iterator<Integer> iterator = arr.iterator();
        while (iterator.hasNext()){
            Integer next = iterator.next();
            if (next%2==0){
                iterator.remove();
                System.out.println(next);
            }

        }

        arr.forEach(System.out::print);

        System.out.println("--------------------------------------------------------");
        Iterator<Integer> iterator2 = arr.iterator();
        while(iterator2.hasNext())
            System.out.println(iterator2.next());



    }



}
